home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / ASTRNOMY / SFS101S.ZIP / RO101.ZIP / RO.C < prev    next >
C/C++ Source or Header  |  1991-11-04  |  19KB  |  781 lines

  1. /********************************************************/
  2. /*                            */
  3. /*    ro.c        main program file for ro    */
  4. /*                            */
  5. /*    ro version 1.10                    */
  6. /*                            */
  7. /*    Portions copyright (c) 1989 by Ted A. Campbell    */
  8. /*        Bywater Software            */
  9. /*        P. O. Box 4023                */
  10. /*        Duke Station                */
  11. /*        Durham, NC  27706            */
  12. /*                            */
  13. /*    Contains portions of ROFF4, Version 1.60    */
  14. /*      (c) 1983, 4 by Ernest E. Bergmann               */
  15. /*        Physics, Building #16            */
  16. /*        Lehigh University            */
  17. /*        Bethlehem, Pa. 18015            */
  18. /*                            */
  19. /*    Contains portions of ROFF4, Version 1.61    */
  20. /*      (c) 1985 by Konrad Kwok                         */
  21. /*        20 3rd Street, Section M        */
  22. /*        Fariview Park,                */
  23. /*        Hong Kong                */
  24. /*                            */
  25. /*    ro and its predecessor ROFF4 are based on     */
  26. /*    the ROFF text processor described in Kernigan    */
  27. /*    and Plauger's now-classic text <Software Tools> */
  28. /*                            */
  29. /* Permission is hereby granted for all commercial and    */
  30. /* non-commercial reproduction and distribution of this */
  31. /* material provided this notice is included.        */
  32. /*                            */
  33. /********************************************************/
  34.  
  35. #include "ro.h"
  36.  
  37. extern  char *ro_gets();
  38.  
  39. int ro_iline = 0;
  40. int ro_deno = 0;
  41.  
  42. /*****************MAIN************MAIN*********/
  43.  
  44. main( argc, argv )
  45.    int argc;
  46.    char **argv;
  47.    {
  48.    register int n;
  49.    int fs;
  50.    char option;
  51.    char filename[20];
  52.    struct divfd *pd;
  53.  
  54.    ro_lastch = NULL;
  55. #ifdef   DEBUG
  56.    ro_debug = FALSE;
  57. #endif
  58.    ro_verbose = FALSE;
  59.  
  60.    init_defaults();
  61.  
  62.    /***    First process any flags         ***/
  63.  
  64.    for ( n = 1; n < argc; ++n )
  65.       { 
  66.       strcpy( filename, argv[ n ] );
  67.  
  68.       if ( filename[0] == '-' )
  69.          {
  70.          option = filename[1];
  71.          if ( option == 'v' ) 
  72.             {
  73.             ro_verbose = TRUE;
  74.             fprintf( stderr, "ro, version %s \n", VERSION );
  75.             }
  76. #ifdef   DEBUG
  77.          else if ( option == 'x' ) 
  78.             {
  79.             ro_debug = TRUE;
  80.             ro_verbose = TRUE;
  81.             fprintf( stderr, "ro, version %s \n", VERSION );
  82.             }
  83. #endif
  84.          else if ( option == 's' ) ro_pagestop = TRUE;
  85.          else if ( option == 'o' ) range( &filename[2] );
  86. #ifdef   POSTPROCESS
  87.          else if ( option == 'T' ) pp_init( &filename[2] );
  88. #endif
  89.          else if ( option == 'f' ) ro_useff = TRUE;
  90.          continue;
  91.          }
  92.       }
  93.  
  94. #ifdef   DEBUG
  95.    if ( ro_debug == TRUE )
  96.       {
  97.       fprintf( stderr, "DEBUG:  initial .ls setting is %d. \n",
  98.          ro_lsval[0] );
  99.       }
  100. #endif
  101.  
  102.    /* Now process all files named */
  103.  
  104.    fs = 0;
  105.  
  106.    for ( n = 1; n < argc; ++n )
  107.       { 
  108.       strcpy( filename, argv[ n ] );
  109.       if ( filename[0] != '-' )
  110.          {
  111.  
  112.          if( pd = find2( filename, dlink ))
  113.             {
  114.             dclose( pd );
  115.             }
  116.  
  117.          if (( instream = fopen( filename, "r" )) == NULL )
  118.             {
  119.             fprintf( stderr, "Can't open <%s> for input.\n", filename );
  120.              }
  121.          else
  122.             {
  123.             ++fs;      /* inc. number of files */
  124.             if ( ro_verbose == TRUE )
  125.                {
  126.                fprintf( stderr, "Processing <%s>\n", filename );
  127.                }
  128.             dolns();
  129.             }
  130.          }
  131.       }
  132.  
  133.    /* No files opened; take input from stdin */
  134.  
  135.    if ( fs == 0 )
  136.       {
  137.       if ( ro_verbose && ro_pagestop )
  138.          {
  139.          fprintf( stderr, "ERROR:  one cannot use -s (page stop) with standard input. \n" );
  140.          }
  141.       ro_pagestop = FALSE;   /* Cannot use page stop if stdin */
  142.       instream = stdin;
  143.       dolns();
  144.       }
  145.  
  146.    ro_brk();
  147.    ro_vlineno = ro_plval[ 0 ];
  148.    padv();
  149.    if ( ro_useff ) ro_outc( FORMF );
  150.  
  151. #ifdef   POSTPROCESS
  152.    pp_deinit();         /* Deinitialize the post-processor */
  153. #endif
  154.  
  155.    if ( ro_verbose == TRUE )
  156.       {
  157.       fprintf( stderr, "ro processing complete.\n" );
  158.       }
  159.  
  160.    dsclose();                      /* Close all diversions */
  161.    }            /* end main()       */
  162.  
  163. /****************************************/
  164. /* do processing of lines       */
  165. /****************************************/
  166.  
  167. dolns() 
  168.    {
  169.    char *pc;
  170.    struct divfd *sptr;
  171.    static char name[ 12 ];
  172.    ro_binp = 0;
  173.  
  174.    while ( !feof( instream ) | ro_fptr | ro_binp )
  175.       {
  176.       ro_gets( ro_curline );
  177.       ++ro_iline;
  178.  
  179. #ifdef   DEBUG
  180.       if ( ro_debug == TRUE )
  181.          {
  182.          fprintf( stderr, "DEBUG:  input line # %d <%s> \n",
  183.             ro_iline, ro_curline );
  184.          fprintf( stderr, "DEBUG:  ro_curline[0] is <%c> (0x%x)\n", 
  185.             ro_curline[0], ro_curline[0] );
  186.          }
  187. #endif
  188.  
  189.       if ( ro_curline[ 0 ] == COMMAND )
  190.          {
  191.          name[ 0 ] = ro_curline[ 1 ];
  192.  
  193.          if ( class( ro_curline[ 2 ] ) == BLACK )
  194.             {
  195.             name[ 1 ] = ro_curline[ 2 ];
  196.             name[ 2 ] = '\0';
  197.             }
  198.          else
  199.             {
  200.             name[ 1 ] = '\0';
  201.             }
  202.  
  203.          if ( ( pc = macq( ro_curline )) != NULL )
  204.             {
  205.             pbmac( pc, ro_curline );
  206.             }
  207.          else if ( ( sptr = find2( name, dlink )) != NULL )
  208.             {
  209.             read_div( sptr );
  210.             }
  211.          else
  212.             {
  213.             command( ro_curline );
  214.             }
  215.          }
  216.       else
  217.          {
  218.          text( ro_curline );
  219.          }
  220.  
  221.       if ( feof( instream) )
  222.          {
  223.          endso();
  224.          }
  225.       }
  226.    }
  227.  
  228. char *
  229. ro_gets( line )
  230.    char *line;
  231.    {
  232.    char *l;
  233.  
  234.    l = line;
  235.    do
  236.       {
  237.       *l = ro_getch();
  238.       ++l;
  239.       }
  240.    while( *(l - 1) != '\n' );
  241.  
  242.    *( l - 1 ) = '\0';
  243.  
  244. #ifdef   DEBUG
  245.    if ( ro_debug == TRUE )
  246.       {
  247.       fprintf( stderr, "DEBUG:  ro_gets() <%s> \n", line );
  248.       }
  249. #endif
  250.  
  251.    return line;
  252.    }
  253.  
  254. char
  255. ro_getch()
  256.    {
  257.    register int c;
  258.    static int bflag = FALSE;   /* was last character BACKSLASH? */
  259.  
  260.    while ( TRUE )
  261.       {
  262.       if ( ro_binp == 0 )
  263.          {
  264.          if ( feof( instream ))
  265.             {
  266.             return '\n';
  267.             }
  268.          c = fgetc( instream );
  269.          }
  270.       else
  271.          {
  272.          c = ro_backbuf[ ro_binp-- ];
  273.          }
  274.       switch ( c )
  275.          {
  276.          case EOF:
  277.             bflag = FALSE;
  278.             return '\n';
  279.          case '\r':
  280.             bflag = FALSE;
  281.             break;
  282.          case BACKSLASH:
  283.             if ( !bflag )
  284.                {
  285.                bflag = TRUE;
  286.                if ( ro_expand() == PASSBACK )
  287.                   {
  288.                   return BACKSLASH;
  289.                   }
  290.                else
  291.                   {
  292.                   return ro_getch();
  293.                   }
  294.                }
  295.             else
  296.                {
  297.                bflag = FALSE;
  298.                return c;
  299.                }
  300.          default:
  301.             bflag = FALSE;
  302.             return c;
  303.          }
  304.       }
  305.    }
  306.  
  307. /**************************************************************
  308.  
  309. initializes the global variables governing the execution of the
  310.  format commands.
  311.  
  312. **************************************************************/
  313.  
  314. init_defaults()
  315.    {
  316.    static time_t now;
  317.    struct tm *ltime;
  318.  
  319.    initsk( ro_fill,  FI_DEF);   /* yes we want filled lines */
  320.    initsk( ro_lsval, LS_DEF);   /* line spacing = 1 */
  321.    initsk( ro_inval, IN_DEF);   /* left margin indent   0 */
  322.    initsk( ro_rmval, RM_DEF);   /* right margin = page width   */
  323.    initsk( ro_tcval, TC_DEF);
  324.    initsk( ro_plval, PL_DEF);
  325.    initsk( ro_m1val, M1_DEF);
  326.    initsk( ro_m2val, M2_DEF);
  327.    initsk( ro_m3val, M3_DEF);
  328.    initsk( ro_m4val, M4_DEF);
  329.    initsk( ro_scval, SC_INI);
  330.    initsk( ro_tabsiz, TS_DEF);
  331.    initsk( ro_cfval, CF_DEF);
  332.    initsk( ro_icval, IC_DEF);
  333.  
  334.    ro_tival = IN_DEF;    /* left margin temporary indent   0 */
  335.    ro_ceval = 0;      /* next n lines to be centered - 0 */
  336.    ro_pagestop = FALSE;
  337.    ro_useff = FF_INI;
  338.    ro_firstpage = 1;
  339.    ro_lastpage = 30000;   /*infinite*/
  340.    ro_adjust = JU_INI;
  341.    ro_poval = PO_DEF;
  342.  
  343.    ro_curpag = 0;
  344.    ro_newpag = 1;
  345.    ro_frq = 0;
  346.    ro_frstring = ro_whstring = NULL;
  347.    ro_frval = 1;
  348.    ro_vflineno = ro_pflineno = ro_plineno = 0;
  349.    ro_vlineno = -1;
  350.    ro_bottom = ro_plval[0] - ro_m3val[0] - ro_m4val[0];
  351.    ro_outw = ro_outpos = ro_outtop = ro_outbot = ro_oldln = ro_oldbot = ro_outwrds = 0;
  352.    ro_outbuf [0] = '\0';
  353.    ro_dir = 0;
  354.    ro_eh2[0] = ro_eh3[0] = ro_ehead[0] = '\0';
  355.    ro_oh2[0] = ro_oh3[0] = ro_ohead[0] = '\0';
  356.    ro_ef2[0] = ro_ef3[0] = ro_efoot[0] = '\0';
  357.    ro_of2[0] = ro_of3[0] = ro_ofoot[0] = '\0';
  358.    memfill( ro_cptr, 2*(128-' '), 0);
  359.    memfill( ro_tptr, 2*(128-' '), 0);
  360.  
  361.    ro_out2buf[ 0 ] = ro_bpos = 0;
  362.    initxu();      /* Initialize overstrike and other variables */
  363.    ro_mcnt=1;
  364.    ro_uf = ro_xf = FALSE;
  365.    memfill( ro_dbuf, LSZ, FALSE);
  366.    ro_dpos = -1;
  367.    ro_fptr = 0;          
  368.    mlink = dlink = rlink = slink = NULL;
  369.    ro_kptr = ro_kline;
  370.    *ro_kline=0;
  371.    ro_keybd=FALSE;
  372.  
  373.    /***   now set up some pre-defined registers ***/ 
  374.  
  375.    time( &now );
  376.    ltime = localtime( &now );
  377.    preregister( "dy", ltime->tm_mday );
  378.    preregister( "mo", ltime->tm_mon + 1 );
  379.    preregister( "yr", ltime->tm_year );
  380.    preregister( "%", ro_curpag );
  381.    }
  382.  
  383. /**************************************************************
  384. performs the formatting command returned by comtyp -sets global
  385.    variables ( indenting, underlining, etc. )
  386. **************************************************************/
  387.  
  388. command( line )
  389.    char *line;
  390.    {
  391.    int c_type;   /* command type   */
  392.    int arg_val;   /* argument value, if any */
  393.    static int arg_typ;    /* relative (+ or -) or absolute */
  394.    char wbuf[20];
  395.  
  396.    c_type = comtyp (line);
  397.  
  398. #ifdef   DEBUG
  399.    if ( ro_debug == TRUE )
  400.       {
  401.       fprintf( stderr, "DEBUG:  command is %d \n", c_type );
  402.       }
  403. #endif
  404.  
  405.    if ( c_type == UNKNOWN )
  406.       {
  407.       if ( ro_verbose == TRUE )
  408.          fprintf( stderr, "%s: unknown command \n", line);
  409.       return;
  410.       }
  411.    arg_val = get_val( line, &arg_typ );
  412.  
  413. #ifdef   DEBUG
  414.    if ( ro_debug == TRUE )
  415.       {
  416.       fprintf( stderr, "DEBUG:  get_val returned arg_val = %d, arg_typ = %c\n",
  417.          arg_val, arg_typ );
  418.       fprintf( stderr, "DEBUG:  c_type is now %d \n", c_type );
  419.       }
  420. #endif
  421.  
  422.    switch ( c_type )
  423.       {
  424.       case EM :
  425.       case IG : 
  426.          break;      /* ignore remark */
  427.  
  428.       case FI :       /* filled lines   */
  429.          ro_brk();
  430.          ro_fill[0] = YES;
  431.          break;
  432.  
  433.       case NF:               /* non-filled lines */
  434.          ro_brk();
  435.          ro_fill[0] = NO;
  436.          break;
  437.  
  438.       case AD :       /* adjusted (justified) lines   */
  439.          ro_adjust = TRUE;
  440.          break;
  441.  
  442.       case NA :      /* non-adjusted lines    */
  443.          ro_adjust = FALSE;
  444.          break;
  445.  
  446.       case BR :       /* just cause a break */
  447.          ro_brk();
  448.          break;
  449.  
  450.       case LS :       /* set line spacing value */
  451.          setS( ro_lsval, arg_val, arg_typ, LS_DEF, 1, HUGE );
  452.          break;
  453.  
  454.       case TI :       /* set temporary left indent */
  455.          ro_brk();
  456.          set( &ro_tival, arg_val, arg_typ, TI_DEF, 0, ro_rmval );
  457.          break;
  458.  
  459.       case IN :       /* set left indent */
  460.          ro_brk();
  461.          setS( ro_inval, arg_val, arg_typ, IN_DEF, 0, ro_rmval-1 );
  462.          ro_tival = ro_inval[0];
  463.          break;
  464.  
  465.       case LL :      /* set line length (right margin) */
  466.          setS( ro_rmval, arg_val, arg_typ, RM_DEF, ro_tival+1, 256 );
  467.          break;
  468.  
  469.       case CE :    /* center next arg_val lines */
  470.          ro_brk();
  471.          set( &ro_ceval, arg_val, arg_typ, CE_DEF, 0, HUGE);
  472.          break;
  473.  
  474.       case SP :    /* space down arg_val blank lines */
  475.          set( &ro_spval, arg_val, arg_typ, 1, 0, HUGE);
  476.          do_space ( ro_spval );
  477.          break;
  478.  
  479.       case BP :    /* set pageno arg_val - begin page */
  480.          ro_brk();
  481.          if(((ro_vlineno<=0)||(ro_vlineno>=ro_bottom))&&
  482.             (arg_val==NO_VAL)) 
  483.             {
  484.             break;
  485.             }
  486.          if ( ro_vlineno > 0 )
  487.             {
  488.             do_space (HUGE);
  489.             }
  490.          set( &ro_curpag, arg_val, arg_typ, ro_curpag+1, 0, 9999);
  491.          ro_newpag = ro_curpag;
  492.          break;
  493.  
  494.       case NE :    /*"need"*/
  495.          if ( arg_val == NO_VAL ) 
  496.             {
  497.             arg_val = 2;   /*default*/
  498.             }
  499.          need( arg_val );
  500.          break;
  501.  
  502.       case PL :    /* set page length */
  503.          setS( ro_plval, arg_val, arg_typ, PL_DEF,
  504.             ro_m1val[0]+ro_m2val[0]+ro_m3val[0]+ro_m4val[0]+1, HUGE);
  505.          ro_bottom = ro_plval[0] - ro_m3val[0] - ro_m4val[0];
  506.          break;
  507.  
  508.       case TA :    /*tabsize*/
  509.          setS( ro_tabsiz, arg_val, '0', TS_DEF, 1, HUGE);
  510.          break;
  511.  
  512.       case TC :    /* tab character */
  513.          if ( arg_typ ) 
  514.             {
  515.             arg_val=arg_typ;
  516.             }
  517.          setS( ro_tcval, arg_val, '0', TC_DEF, BLANK+1, 127);
  518.          break;
  519.  
  520.       case FT :   /* Set font */
  521.          switch( arg_typ )
  522.             {
  523.             case 'R':
  524.                putback( '\n' );
  525.                putback( ROMAN );
  526.                putback( ESCAPE );
  527.                break;
  528.             case 'I':
  529.                putback( '\n' );
  530.                putback( ITALIC );
  531.                putback( ESCAPE );
  532.                break;
  533.             case 'B':
  534.                putback( '\n' );
  535.                putback( BOLD );
  536.                putback( ESCAPE );
  537.                break;
  538.             default: 
  539.                if ( ro_verbose )
  540.                   {
  541.                   fprintf( stderr, 
  542.                      "ft:  unrecognized font name \"%c\". \n", 
  543.                      arg_typ );
  544.                   }
  545.             }
  546.          break;
  547.  
  548.       case TR :    /*translation string defined here*/
  549.          gettr(); 
  550.          break;
  551.  
  552.       case DS :    /*define string*/
  553.          insert(); 
  554.          break;
  555.  
  556.       case DE :    /*define macro*/
  557.          ++ro_deno;
  558. #ifdef   DEBUG
  559.          if ( ro_debug == TRUE )
  560.             {
  561.             fprintf( stderr, "DEBUG:  .de number %d \n",
  562.                ro_deno );
  563.             }
  564. #endif
  565.          minsert();
  566.          break;
  567.  
  568.       case NR :        /*register variable*/
  569.          dovar(); 
  570.          break;
  571.  
  572.       case DI :    /*diversion to file*/
  573.          dodiv(); 
  574.          break;
  575.  
  576.       case SO :    /*source from file*/
  577.          source(); 
  578.          break;
  579.  
  580.       case PM :   /* print macro definitions */
  581.          showm();
  582.          break;
  583.  
  584.       case PO :   /* page offset */
  585.          set( &ro_poval, arg_val, arg_typ, 1, 0, HUGE );
  586.          break;
  587.  
  588.       case TM :    /* send message to terminal */
  589.          getwrd(ro_curline, wbuf);   /*skip command*/
  590.          skip_blanks(ro_curline);
  591.          trunc_bl(ro_curline);
  592.          fprintf( stderr, "<%s>\n", ro_curline);
  593.          break;
  594.  
  595. #ifdef   NONROFF
  596.  
  597.       case M1:      /* set topmost margin */
  598.          setS( ro_m1val, arg_val, arg_typ, M1_DEF, 0, HUGE);
  599.          break;
  600.  
  601.       case M2:      /* set second top margin */
  602.          setS( ro_m2val, arg_val, arg_typ, M2_DEF, 0, HUGE);
  603.          break;
  604.  
  605.       case M3:      /* set first bottom margin */
  606.          setS( ro_m3val, arg_val, arg_typ, M3_DEF, 0, HUGE);
  607.          ro_bottom = ro_plval[0] - ro_m3val[0] - ro_m4val[0];
  608.          break;
  609.  
  610.       case M4:      /* set bottom-most margin */
  611.          setS( ro_m4val, arg_val, arg_typ, M4_DEF, 0, HUGE);
  612.          ro_bottom = ro_plval[0] - ro_m3val[0] - ro_m4val[0];
  613.          break;
  614.  
  615.       case HE :    /* get header title for pages */
  616.          gettl3 ( line, ro_ehead, ro_eh2, ro_eh3 );
  617.          gettl3 ( line, ro_ohead, ro_oh2, ro_oh3 );
  618.          break;
  619.  
  620.       case OH :    /*get odd header title*/
  621.          gettl3 ( line, ro_ohead, ro_oh2, ro_oh3 );
  622.          break;
  623.  
  624.       case EH :    /*get even header title*/
  625.          gettl3 ( line, ro_ehead, ro_eh2, ro_eh3 );
  626.          break;
  627.  
  628.       case FO :    /* get footer title for pages */
  629.          gettl3 ( line, ro_efoot, ro_ef2, ro_ef3 );
  630.          gettl3 ( line, ro_ofoot, ro_of2, ro_of3 );
  631.          break;
  632.  
  633.       case OF :    /* get odd page footer title*/
  634.          gettl3 ( line, ro_ofoot, ro_of2, ro_of3 );
  635.          break;
  636.  
  637.       case EF :    /* get even page footer title*/
  638.          gettl3 ( line, ro_efoot, ro_ef2, ro_ef3 );
  639.          break;
  640.  
  641.       case ST :    /* stop(pause) at each page?*/
  642.          set( &ro_pagestop, arg_val, '0', YES, NO, YES);
  643.          break;
  644.  
  645.       case BJ :    /*break with right justification*/
  646.          if ( ro_fill ) /*not applicable otherwise*/
  647.             {
  648.             spread(ro_outbuf,
  649.                ro_min( ro_rmval - ro_tival, MAXLINE - 1 ) - ro_outw + 1,
  650.                ro_outwrds);
  651.             ro_brk();
  652.             }
  653.          break;
  654.  
  655.       case FF :    /*formfeed*/
  656.          set( &ro_useff, arg_val, '0', FF_DEF, NO, YES);
  657.          break;
  658.  
  659.       case SC :    /*space character*/
  660.          if ( arg_typ ) 
  661.             {
  662.             arg_val=arg_typ;
  663.             }
  664.          setS( ro_scval, arg_val, '0', SC_INI, BLANK, 127);
  665.          break;
  666.  
  667.       case EX :    /* exit (abort) */
  668.          if ( ro_verbose )
  669.             fprintf( stderr, ".ex:  user abort.  \n");
  670.          exit(-1);       /* tac */
  671.  
  672.       case CF :    /*translate character flag*/
  673.          if ( arg_typ ) 
  674.             {
  675.             arg_val=arg_typ;
  676.             }
  677.          setS( ro_cfval, arg_val, '0', CF_DEF, BLANK+1, 127);
  678.          break;
  679.  
  680.       case IC :    /* insert character for macro replace */
  681.          if ( arg_typ ) 
  682.             {
  683.             arg_val = arg_typ;
  684.             }
  685.          setS( ro_icval, arg_val, '0', IC_DEF, BLANK+1, 127 );
  686.          break;
  687.  
  688.       case SR :       /* print register definitions */
  689.          showr();
  690.          break;
  691.  
  692.       case SS :       /* print string definitions */
  693.          showit();
  694.          break;
  695.  
  696. #endif
  697.  
  698. #ifdef   DEBUG
  699.       case DB :    /* debug */
  700.          set( &ro_debug, arg_val, '0', NO, NO, YES);
  701.          if ( ro_debug == TRUE ) 
  702.             {
  703.             fprintf( stderr, "DEBUG on...\n");
  704.             }
  705.          else 
  706.             {
  707.             fprintf( stderr, "DEBUG...end.\n");
  708.             }
  709.          break;
  710. #endif
  711.  
  712.       default :
  713.          if ( ro_verbose == TRUE )
  714.             {
  715.             fprintf( stderr, "Command %d not found.\n", c_type );
  716.             fprintf( stderr, "        line: <%s> \n", line );
  717.             }
  718.          break;
  719.       }
  720.    }
  721.  
  722. range( s )
  723.    char *s;
  724.    { 
  725.    int num;
  726.    num=0;
  727.    while(isdigit(*s)) num=num*10+(*(s++)-'0');
  728.    if(num) ro_firstpage=num;
  729.    if(*s=='-')
  730.       {
  731.       s++; 
  732.       num=0;
  733.       while(isdigit(*s)) num=num*10+(*(s++)-'0');
  734.       if(num) ro_lastpage=num;
  735.       }
  736.    else   ro_lastpage = ro_firstpage;
  737.    }
  738.  
  739. ro_min( n1, n2 )
  740.    int n1, n2;
  741.    {
  742.    if ( n1 > n2 )
  743.       {
  744.       return n2;
  745.       }
  746.    else
  747.       {
  748.       return n1;
  749.       }
  750.    }
  751.  
  752. ro_max( n1, n2 )
  753.    int n1, n2;
  754.    {
  755.    if ( n1 < n2 )
  756.       {
  757.       return n2;
  758.       }
  759.    else
  760.       {
  761.       return n1;
  762.       }
  763.    }
  764.  
  765. memfill( b, n, c )
  766.    char *b;
  767.    int n;
  768.    char c;
  769.    {
  770.    register int x;
  771.    char *y;
  772.  
  773.    y = b;
  774.    for ( x = 0; x < n; ++x )
  775.       {
  776.       *y = c;
  777.       }
  778.    }
  779.  
  780.  
  781.